package com.bw.controller;

import com.bw.bean.Movie;
import com.bw.bean.Movie1;
import com.bw.bean.Movie2;
import com.bw.bean.Movie3;
import com.bw.service.MovieService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author 梁凯博
 */
@RestController
public class MovieController {

    @Autowired
    MovieService movieService;

    @RequestMapping("list1")
    public Map getList1(){
        List<Movie> list = movieService.getList1();
        return SugarUtil.getMapData(list);
    }

    @RequestMapping("list2")
    public Map getList2(){
        List<Movie> list = movieService.getList2();
        return SugarUtil.getBarData(list);
    }

    @RequestMapping("list3")
    public Map getList3(){
        List<Movie> list = movieService.getList3();
        return SugarUtil.getPieData(list);
    }

    @RequestMapping("list4")
    public Map getList4(){
        List list1 = new ArrayList();
        list1.add("类别");
        list1.add("新用户");
        list1.add("老用户");
        List<Movie1> list2 = movieService.getList4();
        return SugarUtil.getTablePlayData(list1,list2);
    }

    @RequestMapping("list5")
    public Map getList5(){
        List<Movie> list = movieService.getList5();
        return SugarUtil.getBarData(list);
    }

    @RequestMapping("list6")
    public Map getList6(){
        List<Movie> list = movieService.getList6();
        return SugarUtil.getPieData(list);
    }

    @RequestMapping("list7")
    public Map getList7(){
        List<Movie> list = movieService.getList7();
        return  SugarUtil.getPieData(list);
    }

    @RequestMapping("list8")
    public Map getList8(){
        List list2 = new ArrayList();
        list2.add("品牌");
        list2.add("性别");
        list2.add("总金额");
        List<Movie2> list3 = movieService.getList8();
        return SugarUtil.getTablePlayData(list2,list3);
    }

    @RequestMapping("list9")
    public Map getList9(){
        List<Movie> list = movieService.getList9();
        return SugarUtil.getPieData(list);
    }

    @RequestMapping("list10")
    public Map getList10(){
        List<Movie> list = movieService.getList10();
        return SugarUtil.getBarData(list);
    }

    @RequestMapping("list11")
    public Map getList11(){
        Double val = movieService.getList11();
        return SugarUtil.getFlipNumberData(val);
    }

    @RequestMapping("list12")
    public Map getList12(){
        List list2 = new ArrayList();
        list2.add("组名");
        list2.add("金额");
        List<Movie3> list3 = movieService.getList12();
        return SugarUtil.getTablePlayData(list2,list3);
    }
}
